package org.komarichin.beans.service;

import org.komarichin.beans.IArticle;
import org.komarichin.beans.ILanguage;

import java.io.Serializable;
import java.util.Collection;

/**
 * <p>
 * &nbsp;
 * </p>
 * User: Michael Komarichin
 * Date: Jan 23, 2010
 * Time: 9:24:16 PM
 */
public interface IArticleService<PK> extends Serializable {
    /**
     * save entity
     *
     * @param article saving entity
     * @return saved entity
     */
    IArticle<PK> save(IArticle<PK> article);

    /**
     * save or update entity
     *
     * @param article saving or updation entity
     */
    void saveOrUpdate(IArticle<PK> article);

    /**
     * @param article removed entity
     */
    void remove(IArticle<PK> article);

    /**
     * @param id entity's id for removed
     */
    void remove(PK id);

    /**
     * @param id identifier entity
     * @return found entity
     */
    IArticle<PK> findById(PK id);

    /**
     * @return collection of entities
     */
    Collection<IArticle<PK>> getAll();

    /**
     * @param start     start , default = 0
     * @param limit     limit default 20
     * @param fieldName sorted field name
     * @param order     sorted order
     * @return collection of entities
     */
    Collection<IArticle<PK>> getArticles(int start, int limit, String fieldName, boolean order);

    /**
     * @return count entiteis
     */
    int getCountArticles();

    /**
     * @return latest entites, sorted by date created
     */
    Collection<IArticle<PK>> getLatestArticles();

    /**
     * @param lang language
     * @return collection of entities by language
     */
    Collection<IArticle<PK>> getAll(ILanguage lang);

    /**
     * @param lang      language
     * @param start     start, default 0
     * @param limit     limin default 20
     * @param fieldName sorted field name
     * @param order     sorted order
     * @return collection of entities
     */
    Collection<IArticle<PK>> getArticles(ILanguage lang, int start, int limit, String fieldName, boolean order);

    /**
     * @param lang language
     * @return cound of entities by language
     */
    int getCountArticles(ILanguage lang);

    /**
     * @param lang language
     * @return latest entities by language
     */
    Collection<IArticle<PK>> getLatestArticles(ILanguage lang);
}
